<?php

class Application_Model_service_DanhMucService implements Application_Model_serviceInf_DanhMucServiceInf {
	protected static $_instance = null;
	
	protected function __construct() {
	
	}
	public static function getInstance() {
		if (self::$_instance == null) {
			self::$_instance = new self ();
		}
		return self::$_instance;
	}
	public function taoDanhMucSanPham($ten, $chuThich) {
		$result=0;
		//save to database
		$save =Application_Model_dataDAO_DanhMucDAO::getInstance();
		$result=$save->insert ( $ten, $chuThich );
		return $result;
	}
	/**
	 * @param int $limit
	 * @param int $page
	 */
	public function layDanhSachDanhMucSanPham() {
		$resutl=array();
		//goi dataDao
		$DAO=Application_Model_dataDAO_DanhMucDAO::getInstance();
		$resutl=$DAO->load();
		return $resutl;
	}

	/**
	 * @param int $id
	 * @param string $tenMoi
	 * @param string $chuThichMoi
	 */
	public function updateDanhMucSanPham($id, $tenMoi, $chuThichMoi) {
		//update xuong database
		$resutl=false;
		$DAO=Application_Model_dataDAO_DanhMucDAO::getInstance();
		$result=$DAO->update($id,$tenMoi,$chuThichMoi);
		return $result;
	}

	/**
	 * @param int $id
	 * return boolean
	 */
	public function xoaDanhMucSanPham($id) {
		//DELETE tren database
		$dele=Application_Model_dataDAO_DanhMucDAO::getInstance();
		return $result=$dele->delete($id);
	}
	/**
	 * @param int $id
	 * return Doi tuong DanhMuc
	 */
	public function loadMotDanhMucSanPham($id) {
		$DAO=Application_Model_dataDAO_DanhMucDAO::getInstance();
		$result=$DAO->loadOne($id);
		return $result;
	}

	
}

?>